﻿using System.Windows.Input;
using ClientOverflow.DataTransferObjects;
using ClientOverflow.ViewModels.Interfaces;
using ClientOverflow.ViewModels.MainMenus;
using ClientOverflow.ViewModels.QuestionsListViewModels;

namespace ClientOverflow.ViewModels.UserProfileViewModels
{
    /// <summary>
    /// TagViewModel is in charge to aggregating tags usage and occurrences for a single entity (such as user).
    /// </summary>
    internal class TagViewModel : ITagViewModel
    {
        private readonly Tag tag;
        public int Occurrences { get; private set; }

        public static ITagViewModel CreateTagViewModel(Tag tag, int occurrences, IMenusViewModel viewModel, IQuestionsFilter filter)
        {
            return new TagViewModel(tag, occurrences, viewModel, filter);
        }

        private TagViewModel(Tag tag, int occurrences, IMenusViewModel viewModel, IQuestionsFilter questionsFilter)
        {
            Occurrences = occurrences;
            this.tag = tag;
            ShowQuestions = new ShowQuestionsCommand(questionsFilter, viewModel);
            ShowUsers = new ShowUsersCommand(tag, viewModel);
        }

        public string TagName
        {
            get { return tag.Name; }
        }

        public ICommand ShowQuestions { get; private set; }
        public ICommand ShowUsers { get; private set; }
    }
}